package com.soft.controller;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.soft.entity.Orderlist;
import com.soft.entity.Orderlistdetails;
import com.soft.service.OrderlistdetailsService;



@RestController
@RequestMapping("/orderlistdetails")
public class OrderlistdetailsController {
@Autowired
private OrderlistdetailsService orderlistdetailsService;

@RequestMapping("/queryByorderlistId")
	public List<Orderlistdetails> queryByorderlistId(Long orderlistId){
		return orderlistdetailsService.queryByorderlistId(orderlistId);
	}

@RequestMapping("/insertOne")
public String insertOne(
        @RequestParam Long orderlistId,
        @RequestParam String foodName,
        @RequestParam Long foodCount,
        @RequestParam Long foodPrice,
        @RequestParam Long detailsAllprice) {
    try {
        int result = orderlistdetailsService.insertOne(orderlistId, foodName, foodCount, foodPrice, detailsAllprice);
        return result > 0 ? "success" : "fail";
    } catch (Exception e) {
        return "fail";
    }
}

}